package model.item;
import java.util.HashMap;
import java.util.Map;
import utilities.*;

public class EquippedInventory implements Archiveable {

	private Map<EquipmentSlot, EquippableItem> equipment;
	
	public EquippedInventory()
	{
		equipment = new HashMap<EquipmentSlot, EquippableItem>();
	}
	
	public EquippedInventory(HashMap<EquipmentSlot, EquippableItem> list)
	{
		equipment = list;
	}
	
	public EquippableItem getEquipment( EquipmentSlot es ) 
	{
		return equipment.get(es); 
	}

	public Map<EquipmentSlot, EquippableItem> getEquipment()
	{
		return equipment;
	}
	
	/**
	 * Equips an item to the correct slot, and if it's already filled, swaps the equipment with what was already there.
	 * @param item
	 * @return
	 */
	public EquippableItem equipItem(EquippableItem item)
	{
		EquipmentSlot slot = item.getEquipmentSlot();
		
		EquippableItem swap = null;
		
		if(equipment.containsKey(slot))
		{
			swap = equipment.remove(slot);
		}
		
		equipment.put(slot, item);
		return swap;
	}
	
	public EquippableItem unequipItem(EquippableItem item)
	{	
		return equipment.remove(item.getEquipmentSlot()) ;
	}
	
	public EquippableItem unequipItem(EquipmentSlot slot)
	{
		
		return equipment.remove(slot);
	}
	
	public Archive save() {
		Archive archive = ArchiveFactory.createArchive();
		
		return archive;
	}
	
	public void load(Archive archive) {
		
	}
	
}
